package cqie.edu.homework2;

import cqie.edu.homework2.domain.po.TUser;
import cqie.edu.homework2.domain.vo.TUserVo;
import cqie.edu.homework2.mapper.TUserMapper;
import cqie.edu.homework2.service.TUserService;
import cqie.edu.homework2.util.MD5;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import static cqie.edu.homework2.util.EncryptionUtil.decrypt;

@SpringBootTest
public class test1 {

    @Autowired
    TUserService tUserService;

    @Autowired
    TUserMapper tUserMapper;

    @Test //测试新增人员方法
    public void test_1() {
        TUser tUser = new TUser();
        tUser.setUsername("admin7");

        tUser.setPassword("111111");
        Long i = tUserService.insert1(tUser);
        System.out.println(i);

    }

    @Test //测试MD5加密是否正常
    public void test_2() {
        TUser tUser = new TUser();
        tUser.setUsername("admin");

        String password = "111111";
        String vpassword = MD5.MD5encrypt(password);
        System.out.println(vpassword);

    }

    @Test  //测试后端解密工具能否正常解密
    public void test_3() throws Exception {
        String encryptedFromFrontend = "mrxGM/uUg4fHZOXx+eW9Pw=="; // 替换为前端生成的字符串
        System.out.println(decrypt(encryptedFromFrontend));
    }

    @Test  // 测试连表查询
    public void test_4() throws Exception {
        TUserVo tUserVo = tUserMapper.selectUserWithDetail(16L);
        System.out.println(tUserVo);

    }
}
